package cn.tedu.spring.boot.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {
    public static final String TEST_QUEUE = "test_queue";
    public static final String TEST_EXCHANGE = "test_exchange";
    public static final String TEST_RK = "test_route";

    @Bean
    public Queue testQueue() {
        return new Queue(TEST_QUEUE);
    }

    @Bean
    public DirectExchange testExchange() {
        return new DirectExchange(TEST_EXCHANGE);
    }

    @Bean
    public Binding testBinding() {
        return BindingBuilder.bind(testQueue()).to(testExchange()).with(TEST_RK);
    }
}
